const fs = require('fs')
const path = require('path')

function fetchDir(flod) {
    var files = fs.readdirSync(flod);
// console.log(files)
    for (let i = 0; i < files.length; i++) {
        let file = files[i];
        // console.log(file)
        let address = path.join(flod, file)
        // console.log(address)
        if (fs.statSync(address).isFile()) {
            fs.unlinkSync(address)
            // fs.unlinkSync(address)
            console.log(address)
        } else if (fs.statSync(address).isDirectory()){
            fetchDir(address)
            fs.rmdirSync(address)
            fs.rmdirSync(flod)
            console.log(address)
        }
    } 
}
fetchDir('demo3')